package cn.ctodb.cms.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A CmsTxt.
 */
@Entity
@Table(name = "cms_txt")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "cmstxt")
public class CmsTxt implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "page")
    private Integer page;

    @Lob
    @Column(name = "txt")
    private String txt;

    @ManyToOne
    private CmsChannel cmsChannel;

    @ManyToOne
    private CmsContent cmsContent;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Integer getPage() {
        return page;
    }

    public CmsTxt page(Integer page) {
        this.page = page;
        return this;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public String getTxt() {
        return txt;
    }

    public CmsTxt txt(String txt) {
        this.txt = txt;
        return this;
    }

    public void setTxt(String txt) {
        this.txt = txt;
    }

    public CmsChannel getCmsChannel() {
        return cmsChannel;
    }

    public CmsTxt cmsChannel(CmsChannel cmsChannel) {
        this.cmsChannel = cmsChannel;
        return this;
    }

    public void setCmsChannel(CmsChannel cmsChannel) {
        this.cmsChannel = cmsChannel;
    }

    public CmsContent getCmsContent() {
        return cmsContent;
    }

    public CmsTxt cmsContent(CmsContent cmsContent) {
        this.cmsContent = cmsContent;
        return this;
    }

    public void setCmsContent(CmsContent cmsContent) {
        this.cmsContent = cmsContent;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CmsTxt cmsTxt = (CmsTxt) o;
        if (cmsTxt.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, cmsTxt.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "CmsTxt{" +
            "id=" + id +
            ", page='" + page + "'" +
            ", txt='" + txt + "'" +
            '}';
    }
}
